home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 11 / CU Amiga Magazine's Super CD-ROM 11 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-06].iso / cucd / graphics / dsscripts / polygon.dsrx < prev    next >
Text File  |  1997-03-08  |  3KB  |  123 lines

  1. /* Allow commands to return results */
  2.  
  3. options results
  4.  
  5. /* On error, goto ERROR:. Comment out this line if you wish to */
  6. /* perform your own error checking. */
  7.  
  8. signal on error
  9.  
  10. 'PROJECT_LOCK'
  11.  
  12. /* BEGIN PROGRAM *************************************************/
  13.  
  14. /* ++++++++++++++++++++++++++++++++ */
  15. /* +                              + */
  16. /* + Polygon drawing ARexx script + */
  17. /* +                              + */
  18. /* +    Written by Andrew Elia    + */
  19. /* +                              + */
  20. /* ++++++++++++++++++++++++++++++++ */
  21.  
  22. SIDES=9            /* Sets the number of sides -in this case a nonagon */
  23. SIZE=10            /* Sets the size of the object */
  24. CENX=10            /* The horizontal centre of the object */
  25. CENY=10            /* The vertical centre of the object */
  26. UNIT="cm"        /* Sets the units */
  27.  
  28. /* Opens the library required for trigonometric functions */
  29.  
  30. call addlib("rexxmathlib.library", 0, -30, 0)
  31.  
  32. /* Variables which are used for converting Degrees to Radians */
  33. /* (because rexxmathlib.library works in Radians), as well as */
  34. /* the size of the angle between each vertex */
  35.  
  36. CONVERT=PI(0)/180
  37. ANG=0
  38. SLICE=360/SIDES
  39.  
  40. /* Draws the first point */
  41.  
  42. X=(Sin(ANG*CONVERT)*SIZE)+CENX
  43. Y=(Cos(ANG*CONVERT)*SIZE)+CENY
  44. MYSTRING = "CREATE_BEZIER CLOSED "||X||UNIT||" "||Y||UNIT
  45.  
  46. /* and the rest of them */
  47.  
  48. Do N=1 To (SIDES-1)
  49. ANG=ANG+SLICE
  50. X=(Sin(ANG*CONVERT)*SIZE)+CENX
  51. Y=(Cos(ANG*CONVERT)*SIZE)+CENY
  52. MYSTRING = MYSTRING||" L "||X||UNIT||" "||Y||UNIT
  53. End N
  54.  
  55. /* This passes the data on to DrawStudio for drawing */
  56.  
  57. Interpret MYSTRING
  58.  
  59. /* END PROGRAM ***************************************************/
  60.  
  61. 'PROJECT_UNLOCK'
  62.  
  63. exit
  64.  
  65. /* On ERROR */
  66.  
  67. ERROR:
  68.  
  69. 'PROJECT_UNLOCK'
  70.  
  71. /* If we get here, either an error occurred with the command's */
  72. /* execution or there was an error with the command itself. */
  73. /* In the former case, rc2 contains the error message and in */
  74. /* the latter, rc2 contains an error number. SIGL contains */
  75. /* the line number of the command which caused the jump */
  76. /* to ERROR: */
  77.  
  78. if datatype(rc2,'NUMERIC') == 1 then do
  79.     /* See if we can describe the error with a string */
  80.  
  81.     select
  82.         when rc2 == 103 then
  83.             err_string = "ERROR 103, "||,
  84.                 "out of memory at line "||SIGL
  85.         when rc2 == 114 then
  86.             err_string = "ERROR 114, "||,
  87.                 "bad command template at line "||SIGL
  88.         when rc2 == 115 then
  89.             err_string = "ERROR 115, "||,
  90.                 "bad number for /N argument at line "||SIGL
  91.         when rc2 == 116 then
  92.             err_string = "ERROR 116, "||,
  93.                 "required argument missing at line "||SIGL
  94.         when rc2 == 117 then
  95.             err_string = "ERROR 117, "||,
  96.                 "value after keywork missing at line "||SIGL
  97.         when rc2 == 118 then
  98.             err_string = "ERROR 118, "||,
  99.                 "wrong number of arguments at line "||SIGL
  100.         when rc2 == 119 then
  101.             err_string = "ERROR 119, "||,
  102.                 "unmatched quotes at line "||SIGL
  103.         when rc2 == 120 then
  104.             err_string = "ERROR 120, "||,
  105.                 "line too long at line "||SIGL
  106.         when rc2 == 236 then
  107.             err_string = "ERROR 236, "||,
  108.                 "unknown command at line "||SIGL
  109.         otherwise
  110.             err_string = "ERROR "||rc2||", at line "||SIGL
  111.         end
  112.     end
  113. else if rc2 == 'RC2' then do
  114.     err_string = "ERROR in command at line "||SIGL
  115.     end
  116. else do
  117.     err_string = rc2||", line "||SIGL
  118.     end
  119.  
  120. req_message TEXT '"'err_string'"'
  121.  
  122. exit
  123.